// Override the Page Visibility API
Object.defineProperty(document, "visibilityState", {
  get: () => "visible",
});

Object.defineProperty(document, "hidden", {
  get: () => false,
});

Object.defineProperty(document, "webkitHidden", {
  get: () => false,
});

Object.defineProperty(document, "mozHidden", {
  get: () => false,
});

let totalSeconds;
// Select the element with the class name "marker-name"
const markerElement = document.querySelector(".marker-name");

if (markerElement) {
  // Get the time string from the element's text content
  const timeString = markerElement.textContent.split(" ")[0];

  // Split the time string into hours, minutes, and seconds
  const [hours, minutes, seconds] = timeString.split(":");

  // Convert the time to seconds
  totalSeconds =
    parseInt(hours, 10) * 3600 +
    parseInt(minutes, 10) * 60 +
    parseInt(seconds, 10);
} else {
  // Select the element with the class name "vjs-duration-display"
  const durationElement = document.querySelector(".vjs-duration-display");

  // Get the time string from the element's text content
  const timeString = durationElement.textContent;

  // Split the time string into minutes and seconds
  const [minutes, seconds] = timeString.split(":");

  // Convert the time to seconds
  totalSeconds = parseInt(minutes, 10) * 60 + parseInt(seconds, 10);
}

const vidplayer = document.querySelector('[id^="vjs_video_"]').player;

vidplayer.on("seeking", function (ev) {
  vidplayer.currentTime(totalSeconds - 10);
});
